package GUI.UI
{
    import flash.display.Sprite;
    
    public class UIDecorated extends UIContainer
    {
        protected var _decorationStruc:UIDecorationStruct;
        
        public function UIDecorated(baseSprite:Sprite)
        {
            super(baseSprite);
        }
        
        public function decorate(decoration:UIDecorationStruct):void
        {
            _decorationStruc = decoration;
            
            drawDecoration();
        }
        
        protected function drawDecoration():void
        {
            if(!_decorationStruc)
                return;
            
            var borderThickness:Number = _decorationStruc.borderThickness;
            
            
            this.graphics.beginFill (_decorationStruc.backgroundColor, _decorationStruc.backgroundAlpha);
            this.graphics.drawRect  (0, 0, viewRectWidth, viewRectHeight);
            this.graphics.endFill   ();
            
            this.graphics.lineStyle (borderThickness, _decorationStruc.borderColor, _decorationStruc.borderAlpha);
            this.graphics.moveTo    (                            0,                              0);
            this.graphics.lineTo    (viewRectWidth-borderThickness,                              0);
            this.graphics.lineTo    (viewRectWidth-borderThickness, viewRectHeight-borderThickness);
            this.graphics.lineTo    (                            0, viewRectHeight-borderThickness);
            this.graphics.lineTo    (                            0,                              0);
        }
    }
}